package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.smzq.modular.kcl.entity.Wjglb;
import vip.xiaonuo.smzq.modular.kcl.entity.Zsk;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.Zlxqcx;
import vip.xiaonuo.smzq.modular.kcl.service.IWjglbService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 资料上传文件关联表
 *
 * @author sqq
 * @since 2024-03-13
 */
@Api(tags = "资料上传文件关联表")
@RestController
@RequestMapping("/kcl/wjglb")
@Validated
public class WjglbController {

    @Resource
    private IWjglbService iWjglbService;

    /**
     * 添加资料上传文件关联表
     */
    @ApiOperation("添加资料上传文件关联表")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Wjglb wjglb) {
        iWjglbService.save(wjglb);
        return CommonResult.ok();
    }

    /**
     * 删除资料上传文件关联表
     */
    @ApiOperation("删除资料上传文件关联表")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestBody @Valid Wjglb wjglb) {
        iWjglbService.removeById(wjglb.getPkid());
        return CommonResult.ok();
    }

    /**
     * 编辑资料上传文件关联表
     */
    @ApiOperation("编辑资料上传文件关联表")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Wjglb wjglb) {
        iWjglbService.updateById(wjglb);
        return CommonResult.ok();
    }

    /**
     * 资料上传文件关联表分页查询
     */
    @ApiOperation("资料上传文件关联表分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Wjglb>> page() {
        return CommonResult.data(iWjglbService.page(new Wjglb()));
    }
    /**
     * 资料上传文件列表查询
     */
    @ApiOperation("资料上传文件列表查询")
    @GetMapping("/getZlxqcxList")
    public CommonResult<List<Zlxqcx>> getZlxqcxList(
            @ApiParam(name = "nd", value = "年度",  required = true) @RequestParam Integer nd,
            @ApiParam(name = "kqbm", value = "矿区编码",  required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码",  required = true) @RequestParam Integer djflbm
    ) {
        return CommonResult.data(iWjglbService.getZlxqcxList(djflbm, kqbm, nd));
    }



    /**
     * 文件上传通用接口
     */
    @ApiOperation("文件上传通用接口")
    @PostMapping("/fileUpload")
    public CommonResult<String> fileUpload(
            @RequestPart("files") MultipartFile file

    ) {
        return CommonResult.data(iWjglbService.fileUpload(file));
    }

    /**
     * 文件批量下载
     */
    @ApiOperation("文件批量下载")
    @GetMapping("/filesDownload")
    public void preview(@ApiParam(name = "fileId", value = "文件ID：多个用逗号隔开 例：1,2,3",  required = true) @RequestParam String fileId) {
        iWjglbService.filesDownload(fileId);
    }











}
